package cn.tedu.shoot;
import java.awt.image.BufferedImage;

public class Hero extends FlyingObject {
    public static final int FIRE = 0;            //正常火力
    public static final int STRENGTHEN_FIRE = 1; //加强火力
    public int state = FIRE;                     //默认状态
    private int life;                            //命
    private int score;                           //分数
    private int i = 0;                           //图片数组下标

    public String toString() {
        return "Hero{" +
                "life=" + life +
                ", score=" + score +
                '}';
    }

    /**
     *查看分
     */
    public int getScore() {
        return score;
    }

    /**
     *查看命
     */
    public int getLife() {
        return life;
    }

    /**
     * 加命
     */
    public void setLife(int life) {
        this.life += life;
    }

    /**
     * 加分
     */
    public void setScore(int score) {
        this.score += score;
    }

    /**
     * 减命
     */
    public void detLife() {
        this.life -= 1;
    }

    /**
     * 构造方法
     */
    public Hero() {
        super(97, 139, 140, 400);
        life = 3;
    }

    /**
     * 重写step()移动
     */
    public void step() {
    }

    /**
     * 生成子弹
     */
    public Bullet setBullet() {
            int x = this.x + this.width / 2 - 5;
            int y = this.y;
            return new Bullet(x, y);
    }
    public Bullet setBullet2() {
        int x = this.x + this.width / 2 - 5;
        int y = this.y;
        return new Bullet(x-43, y+40);
    }
    public Bullet setBullet3() {
        int x = this.x + this.width / 2 - 5;
        int y = this.y;
        return new Bullet(x+43, y+40);
    }

    /**
     * 循环切换英雄机图片
     */
    public BufferedImage inImages() {
        return Images.heros[i++ % Images.heros.length];//
    }

    /**
     *独有的移动方法
     */
    public void moveTo(int x, int y) {
        this.x = x - this.width / 2;  //英雄机的x=鼠标的x-1/2英雄机的宽
        this.y = y - this.height / 2; //英雄机的y=鼠标的y-1/2英雄机的高
    }


}
